package com.tjut.core;

import okhttp3.Cookie;
import okhttp3.CookieJar;

import java.util.ArrayList;
import java.util.List;


public abstract class CookieManager implements CookieJar {
    protected final List<Cookie> cookies = new ArrayList<>();

    public List<Cookie> getCookies() {
        return new ArrayList<>(cookies);
    }

    public void clear() {
        cookies.clear();
    }

    public Cookie getCookie(String cookieName) {
        for (Cookie cookie : cookies) {
            if (cookie.name().equals(cookieName)) {
                return cookie;
            }
        }
        return null;
    }
}
